import { renderOption } from '@/utils/echartsOption'

const option = (res) => {
  const options = {
    tooltip: {
      trigger: 'axis',
      formatter: (params) => {
        let str = `${params[0].name}<br/>`
        if (params !== null) {
          for (let i = 0; i < params.length; i++) {
            str += `<span style="display:inline-block;border-radius:5px;margin-right:5px;width:10px;height:10px;background-color:${params[i].color}"></span>`
            const serName = params[i].seriesName
            str += `${serName}:<span>${params[i].value}</span>`
          }
        }
        return str
      }
    },
    grid: {},
    legend: {
      left: 10,
      top: 0,
      show: true
    },
    xAxis: {},
    yAxis: {
      axisLabel: {
        formatter: '{value}%'
      },
      min: 0
    },
    series: res ? res.series : []
  }
  console.log(renderOption('plotxy', options))
  return renderOption('plotxy', options)
}

export default option
